<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<th:block th:include="include :: header('新增货区')"/>
	<style>
		[v-cloak] {
			display: none;
		}
	</style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-areaInfo-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">货区编码：</label>
				<div class="col-sm-8">
					<input id="areaCode" name="areaCode" class="form-control" v-model="uniqueCode" readonly="true">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">货区名称：</label>
				<div class="col-sm-8">
					<input id="areaName" name="areaName" class="form-control" type="text" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="memo" name="memo" class="form-control" type="text" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">仓库：</label>
				<div class="col-sm-8">
					<select id="wareId" name="wareId" class="form-control" >
						<option v-for="ware in wares" :value="ware.wareId" v-cloak>{{ware.wareName}}</option>
					</select>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/areaInfo";

		function submitHandler(){
			if($.validate.form()){
				$.operate.save(prefix + "/add", $('#form-areaInfo-add').serialize());
			}
		};

		var app = new Vue({
			el: '.wrapper',
			data: {
				uniqueCode: '',
				wares: []
			},
			methods: {
				getWares: function(){
					var that = this;
					$.ajax({
						cache: true,
						type: "POST",
						url: "/system/wareInfo/list",
						data: {},
						async: false,
						error: function(request){
							$.modal.alertError("系统错误");
						},
						success: function(data){
							that.wares = data.rows;
						}
					});
				}
			},
			created(){
				this.getWares();
				var date = new Date();
				this.uniqueCode = date.getTime();
			}
		})
	</script>
</body>
</html>
